<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../core/include.inc.jsp"%>

<style>
    .pageFormContent p {
        width: 90%;
    }
</style>
<script type="text/javascript">
    $(".pay-add select[name='blockId']").change(function () {
        var blockName = $(".pay-add select[name='blockId']").val();
        $("#payType1").html("<option value=''>请选择缴费类型</option>");
        $.ajax({
            type:"post",
            url:"get_pay_type",
            data:{"blockName":blockName},
            dataType:"json",
            success:function(data){
                console.log(data);
                $.each(data,function(i, inner) {
                    $("#payType1").append("<option value='"+inner+"'>"+inner+"</option>");
                })
            }
        })
    })
</script>
<div class="pageContent">
    <form method="post" action="pay_add" class="pageForm required-validate pay-add"
          onsubmit="return validateCallback(this, dialogAjaxDone)">

        <div class="pageFormContent nowrap" layoutH="57">
            <p>
                <label>小区名称：</label>
                <select class="combox" name="blockId">
                    <option value="0">全部小区</option>
                    <c:forEach var="item1" items="${blockList}">
                        <option value="${item1.id}">${item1.blockName}</option>
                    </c:forEach>
                </select>
            </p>

            <p>
                <label>物业费户号：</label>
                <input type="text" name="payFeeNum" />
            </p>

            <p>
                <label>详细地址：</label>
                <input type="text" name="payUserAddr" class="required" />
            </p>

            <p>
                <label> 业主姓名：</label>
                <input type="text" name="payUser"
                       class="required" minlength="2" maxlength="20" />
            </p>

            <p>
                <label>业主联系方式：</label>
                <input type="text" name="payUserTel"  class="required" minlength="2" maxlength="20" />
            </p>

            <p>
                <label>缴费类型：</label>
                <select class="" name="payType" id="payType1">
                    <option value="">请选择缴费类型</option>
                </select>
            </p>

            <p>
                <label>收费标准：</label>
                <input type="text" name="payCharge" class="number required" maxlength="20" placeholder="请输入数字"/>
            </p>

            <p>
                <label>应缴金额：</label>
                <input type="text" name="payMoney" class="number required" maxlength="20" placeholder="请输入数字"/>
            </p>

            <p>
                <label>缴费状态：</label>
                <select class="combox" name="payState">
                    <option value="">全部状态</option>
                    <option value="欠费">欠费</option>
                    <option value="正常">正常</option>
                </select>
            </p>

            <p>
                <label>收费日期：</label>
                <input type="text" name="payDate"
                       class="date textInput valid required" datefmt="yyyy-MM-dd"  pattern="yyyy-MM-dd"/>
            </p>

            <p>
                <label>费用周期：</label>
                <input type="text" name="payStartDate" class="date textInput valid required" datefmt="yyyy-MM-dd"  pattern="yyyy-MM-dd"/>
                <input type="text" name="payEndDate" class="date textInput valid required" datefmt="yyyy-MM-dd"  pattern="yyyy-MM-dd"/>
            </p>

            <p>
                <label>备注：</label>
                <input type="text" name="payRemark" />
            </p>

        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent" style="text-align: center;">
                            <button type="submit" onclick="return check()">保存</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script>
    function getFeeType1() {
       var blockName = $("#blockId").val();
        $("#payType1").html("<option value=''>请选择缴费类型</option>");
        $.ajax({
            type:"post",
            url:"get_pay_type",
            data:{"blockName":blockName},
            dataType:"json",
            success:function(data){
                console.log(data);
                $.each(data,function(i, inner) {
                    $("#payType1").append("<option value='"+inner+"'>"+inner+"</option>");
                })
            }
        })
        return false;
    }

    function check() {
        var blockId = $(".pay-add select[name='blockId']").val();
        var payState = $(".pay-add select[name='payState']").val();
        var payType = $(".pay-add select[name='payType']").val();
        var payStartDate = $(".pay-add input[name='payStartDate']").val();
        var payEndDate = $(".pay-add input[name='payEndDate']").val();
        if(payStartDate.split("-")[0] != payEndDate.split("-")[0]){
            alert("请选择周期在本年度内");
            return false;
        }
        if(blockId==0){
            alert("请选择小区");
            return false;
        }
        if(payState==""){
            alert("请选择缴费状态");
            return false;
        }
        if(payType==""){
            alert("请选择缴费类型");
            return false;
        }
    }
</script>